<template>
  <div class="personal-main">
    <el-table :data="borrowInfos" stripe style="width: 100%">
      <el-table-column prop="investAmount" label="投资金额"></el-table-column>
      <el-table-column prop="params.period" label="期数"></el-table-column>
      <el-table-column prop="params.lendYearRate" label="年化率"></el-table-column>
      <el-table-column prop="params.returnMethod" label="还款方式"></el-table-column>
      <el-table-column prop="createTime" label="申请时间"></el-table-column>
      <el-table-column prop="params.status" label="状态"></el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pageNum"
        :page-size="pageSize"
        layout="total, prev, pager, next"
        :total="total">
    </el-pagination>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageNum: 1,
      pageSize: 3,
      borrowInfos: [],
      total: 0,
    };
  },
  mounted() {
    this.initData();
  },
  methods: {
    handleSizeChange(size) {
      this.pageSize = size;
      this.initData();
    },
    handleCurrentChange(num) {
      this.pageNum = num;
      this.initData();
    },
    initData() {
      let token = localStorage.getItem("SRB-TOKEN");
      if (!token) {
        this.$message.warning("请先登录");
        return;
      }
      this.$axios({
        url: `/api/core/lendItem/${this.pageNum}/${this.pageSize}`,
        method: "GET",
        headers: {token},
      }).then((r) => {
        this.borrowInfos = r.data.data.page.records;
        this.total = Number(r.data.data.page.total);
      });
    },
  },
};
</script>
